/******************************************************************************
 Copyright (c) 2022 - 2024 Qualcomm Technologies International, Ltd.
 All Rights Reserved.
 Qualcomm Technologies International, Ltd. Confidential and Proprietary.

 REVISION:      $Revision: #15 $
******************************************************************************/

#ifndef GATT_XPAN_SERVER_HANDOVER_MGR_H_
#define GATT_XPAN_SERVER_HANDOVER_MGR_H_

#include "csr_synergy.h"

#ifndef EXCLUDE_GATT_XPAN_SERVER_MODULE

#include "gatt_xpan_server_private.h"
#include "hydra_types.h"
#include <marshal.h>

#define GATT_XPAN_NUM_CONNECTIONS_MAX 3

/* Definition of data required for handover. */
typedef struct
{
    StoredSsid                  storedSsid;
    Ipv4Address                 ipv4Address;
    Ipv6Address                 ipv6Address;
    TcpPort                     l2capTcpPort;
    UdpPort                     udpPort;
    ServiceUuid                 mDnsSrvUuid[16];
    ConnectedDevices            connectedDevices;
    BearerPreference            bearerPreference;
    MacAddress                  macAddress;
    RequestedSapPowerState      requestedSapPowerState;
    XpanServerFeatures          features;
    PresentDevices              numDevices;
    VoiceBackChannelPeriodicity periodicity;
    TwtStatus                   twtStatus;
    SapConnectionStatus         sapConnectionStatus;
    /* The following fields are 'per client' */
    GattXpanServerConfig        clientConfig;

    TwtConfiguration            twtConfiguration;
    ConnectionId                cid;                       /* <-- NOT handed over, but this field is set during unmarshalling.  */
    /* ClearToSend               clearToSend;               <-- NOT handed over. Set to initial value on new primary after handover: XPAN_CTS_NOT_READY */
    /* XpanAudioBearerSwitchResponse audioBearerStatus;     <-- NOT handed over. Set to initial value on new primary after handover: XPAN_AUDIO_BEARER_SWITCH_RESPONSE_READY */
} GattXpanHandoverData;  /* Based on GattXpanData and GattXpanClientData */

/* Handover manager struct. */
typedef struct XpanHandoverMgr
{
    bool                  marshallerInitialised;
    marshaller_t          marshaller;
    bool                  unMarshallerInitialised;
    unmarshaller_t        unMarshaller;
    GattXpanHandoverData* handoverData;    /* handover data is unmarshalled/marshalled to/from here. This may contain partial data during handover. */
    uint8                 numHandoverConnections;
    GattXpanHandoverData* handoverConnection[GATT_XPAN_NUM_CONNECTIONS_MAX];
} XpanHandoverMgr;

void XpanServerHandoverMgrCleanup(ServiceHandle serviceHandle);

#endif /* EXCLUDE_GATT_XPAN_SERVER_MODULE */

#endif /* GATT_XPAN_SERVER_HANDOVER_MGR_H_ */
